package com.igame.garbage;

import java.net.URL;

import com.jme.app.SimpleGame;
import com.jme.image.Texture;
import com.jme.image.Texture.MagnificationFilter;
import com.jme.image.Texture.MinificationFilter;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.TextureState;
import com.jme.util.TextureManager;

public class TryQuad extends SimpleGame{

	@Override
	protected void simpleInitGame() {
		scene = this.rootNode;
		initScene();
		scene.updateGeometricState(0, true);
		scene.updateRenderState();
	}
	
	public TryQuad(){
		scene = this.rootNode;
	}
	
	private Node scene;
	
	String groundimagefile = "media/images/testground.jpg";
	private void initScene(){
		//create a plane as the level
		Quad ground = new Quad("playground", 10, 10);
		//Sphere ground = new Sphere("playground",30,30,10);
		ground.setLocalTranslation(0, 0, 0);
		//ground.setRenderQueueMode(Renderer.QUEUE_ORTHO);
		
		//bind texture to ground
		TextureState txground = display.getRenderer().createTextureState();
		URL imageurl = this.getClass().getClassLoader().getResource(groundimagefile);
		Texture tx = TextureManager.loadTexture(imageurl, MinificationFilter.Trilinear, MagnificationFilter.Bilinear);
		txground.setTexture(tx);
		ground.setRenderState(txground);
		ground.updateRenderState();
		
		scene.attachChild(ground);
	}
}
